<script type="text/javascript" charset="utf-8">
<%- session_key = Rails.application.config.session_options[:key] -%> 
$(document).ready(function() {
	
	$('#upload_photo').click(function(event){ 
		event.preventDefault();
	}); 
	
	$('#upload_photo').uploadify({
  	uploader : '<%= asset_path("uploadify.swf") %>',
		cancelImg : '<%= asset_path("/uploadify/cancel.png") %>',
		multi : true,
		auto : true,
  	script : '/admin/uploads',
		onComplete : function(event, queueID, fileObj, response, data) { 
			var dat = eval('(' + response + ')');
			$.getScript(dat.upload);},
  	scriptData : {
	        '_http_accept': 'application/javascript',
					'format' : 'json',
	        '_method': 'post',
	        '<%= session_key %>' : encodeURIComponent('<%= u cookies[session_key] %>'),
	        'authenticity_token': encodeURIComponent('<%= u form_authenticity_token %>'),
					'imageable_id' : '<%= article.id %>',
					'imageable_type' : '<%= article.class.name %>'
	      }
	});
	
	$('#upload_submit').click(function(event){ 
			event.preventDefault(); 
			$('#upload_photo').uploadifyUpload(); 
		});
		
}); 
</script>

